<?php
$this->title = '添加帮助信息';
$this->params['breadcrumbs'][] = ['label' => '帮助中心', 'url' => ['list']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div>
    <?php $form = \yii\widgets\ActiveForm::begin(); ?>

    <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>

    <?php echo $form->field($model, 'content')->widget('kucha\ueditor\UEditor',['server'=>common\helper\UrlManager::createUrl(Yii::$app->params['domains']['upload'],['ueditor-upload/upload'])]) ?>

    <?= $form->field($model, 'is_show')->radioList(['不显示', '显示']) ?>

    <input type="button" name="submit_btn" id="submit_btn" value="添加" class="btn btn-success">

    <?php \yii\widgets\ActiveForm::end(); ?>
</div>

<?php $this->beginBlock('js'); ?>
<script>
$(function() {
    $("#submit_btn").click(function() {
        var ue = UE.getEditor('helpcenter-content');
        if(ue.getContent() == "") {
            alert("请输入内容");
            return false;
        }

        $.post("<?= \Yii::$app->urlManager->createUrl((\Yii::$app->controller->id . '/add')) ?>", $("#w0").serialize(), function(json) {
            if(!json.flag) {
                alert(json.msg);
            } else {
                window.location.href = "<?= \Yii::$app->urlManager->createUrl((\Yii::$app->controller->id . '/list')) ?>";
            }
        }, "json");
    });
});
</script>
<?php $this->endBlock(); ?>